package com.d17_homework.homework5;

import java.io.InputStream;
import java.lang.reflect.Method;
import java.util.Properties;

public class Demo5 {
    public static void main(String[] args) throws Exception {
        //读取配置文件
        ClassLoader classLoader = ClassLoader.getSystemClassLoader();
        InputStream stream = classLoader.getResourceAsStream("prop.properties");
        //属性集
        Properties pro = new Properties();
        pro.load(stream);
        //获取属性名
        String className = pro.getProperty("className");
        String methodName = pro.getProperty("methodName");
        //创建反射对象
        Class clazz = Class.forName(className);
        //创建对象
        Object o = clazz.getDeclaredConstructor().newInstance();
        //获取方法
        Method method = clazz.getDeclaredMethod(methodName);
        //执行
        method.invoke(o);
    }
}
